#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

class Solution {
public:
    void setZeroes(vector<vector<int>>& matrix) {
        for(int i =0 ;i<matrix.size();++i){
            for(int  j = 0;j<matrix[0].size();++j){
                if(matrix[i][j]==0){
                    func(matrix,i,j);
                }
            }
        }
        for(int i=0;i<matrix.size();++i){
            for(int j = 0;j<matrix[0].size();++j){
                if(matrix[i][j]==INT16_MAX){
                    matrix[i][j]=0;
                }
            }
        }
    }
    void func(vector<vector<int>>& matrix,int i,int j){
        //将第i行和第j列全转为INT_MAX
        
            matrix[i][j] = INT16_MAX;
            for(int t = 0;t<matrix[0].size();++t){
                if(matrix[i][t]!=0)
                    matrix[i][t] = INT16_MAX;
            }
        
        
            for(int t = 0;t<matrix.size();++t){
                if(matrix[t][j]!=0)
                    matrix[t][j] = INT16_MAX;
            }
        
    }
};


int main(){
    Solution S;
    vector<vector<int>> matrix = {{0,1,2,0},{3,4,5,2},{1,3,1,5}};
    S.setZeroes(matrix);
    return 0;
}